package org.dicr.traffic.source;

import java.util.*;

/**
 * Traffic Event
 * 
 * @author <A href='http://dicr.org'>Igor A Tarasov</A>
 * @version 060703
 */
public class TrafficEvent {
	private static long lastId = 0;

	private long id = 0;

	private TrafficSource source = null;

	private Collection<TrafficElement> traffic = null;

	/**
	 * Generate next id.
	 * 
	 * @return next Id.
	 */
	private static synchronized long nextId() {
		TrafficEvent.lastId++;
		return TrafficEvent.lastId;
	}

	/**
	 * Constructor
	 * 
	 * @param theSource traffic source of event
	 * @param theTraffic traffic from source
	 */
	public TrafficEvent(final TrafficSource theSource, final Collection<TrafficElement> theTraffic) {
		if (theSource == null) throw new IllegalArgumentException("null source");
		if (theTraffic == null) throw new IllegalArgumentException("null traffic");
		this.id = TrafficEvent.nextId();
		this.source = theSource;
		this.traffic = theTraffic;
	}

	/**
	 * Return event ID
	 * 
	 * @return id of event
	 */
	public long getId() {
		return this.id;
	}

	/**
	 * Return source
	 * 
	 * @return traffic source
	 */
	public TrafficSource getSource() {
		return this.source;
	}

	/**
	 * Return traffic
	 * 
	 * @return traffic from source
	 */
	public Collection<TrafficElement> getTraffic() {
		return this.traffic;
	}
}
